#! /usr/local/bin/gosh

(use text.html-lite)
(use www.cgi)
(use www.contcgi)

(define (main args)
  (contcgi-main
   (lambda (params)
     (let loop ((counter 0))
       (let1 action (cgi-get-parameter "action"
				       (show `(,(cgi-header)
					       ,(html-doctype)
					       ,(html:html
						 (html:body
						  (html:p (html:b (format "pid = ~a" (sys-getpid))))
						  (html:h1 counter)
						  (html:br)
						  (html:a
						   :href (format #f "./counter.fcgi?cont-count=~a&action=inc" cont-count)
						   "++")
						  "&nbsp"
						  (html:a
						   :href (format #f "./counter.fcgi?cont-count=~a&action=dec" cont-count)
						  "--"))))))
	 (cond
	  ((equal? action "inc") (loop (+ counter 1)))
	  ((equal? action "dec") (loop (- counter 1)))
	  (else (loop counter))))))))

;; Local variables:
;; mode: scheme
;; end:
